﻿using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class TextDoColor : MonoBehaviour
{
	private Text _text;
	private Tweener _tweener1 = null;
	private Tweener _tweener2 = null;

	// Use this for initialization
	void Start ()
	{
		_text = GetComponent<Text>();
	}
	
	// Update is called once per frame
	void Update () {
		
	}

	public void OnClick()
	{
		if (_tweener1 == null)
		{
			_tweener1 = _text.DOColor(Color.red, 2);
			_tweener1.SetAutoKill(false);
			_tweener1.Pause();
		}
		if (_tweener2 == null)
		{
			_tweener2 = _text.DOFade(1, 3);
			_tweener2.SetAutoKill(false);
			_tweener2.Pause();
		}
		
		_tweener1.Restart();
		_tweener2.Restart();
	}

	private void OnDestroy()
	{
		if(_tweener1!=null)
			_tweener1.Kill();
		
		
		if(_tweener2!=null)
			_tweener2.Kill();
	}
}
